//
//  CertificationContainerViewController.m
//  Globalstone
//
//  Created by 辰领科技 on 16/7/11.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "CertificationContainerViewController.h"

@interface CertificationContainerViewController ()
@property (strong, nonatomic) IBOutlet UIView *navView;
@property (strong, nonatomic) IBOutlet UIScrollView *scroview;
@property (strong, nonatomic) IBOutlet UIImageView *imageviewOne;
@property (strong, nonatomic) IBOutlet UIImageView *imageviewTwo;
@property (strong, nonatomic) IBOutlet UIImageView *imageviewThree;
@property (strong, nonatomic) IBOutlet UIImageView *imageviewFour;
@property (strong, nonatomic) IBOutlet UIImageView *imageviewFive;
@property (strong, nonatomic) IBOutlet UIImageView *imageviewSix;
@property (weak, nonatomic) IBOutlet UILabel *certificateDate;

@property (strong, nonatomic) IBOutlet UIImageView *videoImageview;
@property (strong, nonatomic) IBOutlet UIView *VIEW;

@end

@implementation CertificationContainerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initViewLayout];
    if ([_type isEqualToString:@"1"]) {
        [self getContainerCertificationImport];
    }else{
        [self getContainerCertification];
    }
}

- (void)initViewLayout{
    [self adaptiveViewLayout:self.view];
    [self adaptiveViewLayout:self.navView];
    [self adaptiveViewLayout:self.scroview];
    [self adaptiveViewLayout:self.VIEW];
   
    self.scroview.contentSize = flexibleSize(CGSizeMake(320, 505), NO);

    
}


- (IBAction)back:(id)sender {
    [self backBtn];
}

#pragma mark === 进口认证信息
- (void)getContainerCertificationImport{
    NSMutableDictionary  *dic=[NSMutableDictionary dictionary];
    [dic setObject:[Common getLoginInfo][Key_User_userId] forKey:@"museId"];
    [dic setObject:[Common getLoginInfo][Key_User_password] forKey:@"musePwd"];
    [dic setObject:[Common getLoginInfo][Key_User_onlineKey] forKey:@"museOnlineTag"];
    NSString * lan = [InternationalControl userLanguage];
    if ([lan isEqualToString:@"en"]) {
        [dic setObject:@"2" forKey:@"language"];
    }else{
        [dic setObject:@"1" forKey:@"language"];
    }
    [dic setObject:_indentId forKey:@"oimpId"];
    
    self.shareApi.delegate=self;
    [self.shareApi  requestOperationWithDic:dic withPath:GS_queryContainerCertificationImport withHttpType:@"POST" withTag:GS_GS_queryContainerCertificationImport];
}


#pragma mark === 出口认证信息
- (void)getContainerCertification{
    NSMutableDictionary  *dic=[NSMutableDictionary dictionary];
    [dic setObject:[Common getLoginInfo][Key_User_userId] forKey:@"museId"];
    [dic setObject:[Common getLoginInfo][Key_User_password] forKey:@"musePwd"];
    [dic setObject:[Common getLoginInfo][Key_User_onlineKey] forKey:@"museOnlineTag"];
    NSString * lan = [InternationalControl userLanguage];
    if ([lan isEqualToString:@"en"]) {
        [dic setObject:@"2" forKey:@"language"];
    }else{
        [dic setObject:@"1" forKey:@"language"];
    }
    [dic setObject:_indentId forKey:@"oexpId"];
    
    self.shareApi.delegate=self;
    [self.shareApi  requestOperationWithDic:dic withPath:GS_queryContainerCertification withHttpType:@"POST" withTag:GS_GS_queryContainerCertification];
}



#pragma   mark---- GetADBanner Request Delegate

-(void)fetchDatabaseFinished:(NSMutableDictionary *)database withTag:(NSInteger)tag{
    
    if (tag==GS_GS_queryContainerCertification || tag == GS_GS_queryContainerCertificationImport) {
        
        if (  [[database valueForKey:@"flag"] integerValue]!=1 ) {
            
            [[CWHUDTips sharedInstance]  showTips:[database valueForKey:@"msg"]  withStatus:1 dismissAfter:1.5];
            
        }else  {
            if ([database[@"result"]isEqual:[NSNull null]]) {
                return;
            }
            NSDictionary * dic = database[@"result"];
            NSArray * images = [NSArray array];
            NSArray * Images=[NSArray array];
            NSString * imagesStr = @"";
            NSString * ImagesStr= @"";
            if ([_type isEqualToString:@"2"]) {//出口
                imagesStr = [NSString stringWithFormat:@"%@",dic[@"oecoImage"]];
                ImagesStr = [NSString stringWithFormat:@"%@",dic[@"oecoAttach"]];
            }else{
                imagesStr = [NSString stringWithFormat:@"%@",dic[@"oicoLoadImage"]];
                ImagesStr = [NSString stringWithFormat:@"%@",dic[@"oicoOrderInfo"]];
            }
            images = [imagesStr componentsSeparatedByString:@","];
            Images = [ImagesStr componentsSeparatedByString:@","];
            for (int i = 0; i<images.count; i++) {
                UIImageView * image = [self.view viewWithTag:100+i];
                [image sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IP_Address_ImageDown_Fresh,images[i]]]];
            }
            
            for (int i = 0; i<Images.count; i++) {
                UIImageView * image = [self.view viewWithTag:104+i];
                [image sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IP_Address_ImageDown_Fresh,Images[i]]]];
            }

        }
    }
}

-(void)fetchDatabaseFailed:(NSError *)error message:(NSString *)message{
    
    [self dismissWaitDialog];
    
}


@end
